package com.jackeysun.common.anim

import android.graphics.Camera
import android.view.animation.Animation
import android.view.animation.Transformation

/**
 *   Created by sunxunchao on 2021/12/2.
 */
class Rotate3DAnimation(val px: Float, val py: Float) : Animation() {
    private val mCamera = Camera()

    override fun applyTransformation(interpolatedTime: Float, t: Transformation?) {
        val camera = mCamera
        val matrix = t?.matrix
        camera.save()
        camera.rotateY(90f)
        camera.restore()
        matrix?.preTranslate(-px, -py)
        matrix?.postTranslate(px, py)
    }
}